package com.imachen.system.listener;

import com.imachen.system.service.IPermissionService;
import org.springframework.beans.factory.annotation.Autowired;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;

@WebListener //监听器实在项目启动的时候就会执行 - 扫描注解的逻辑卸载这里面
	//程序一启动就会创建上下文对象ServletContext - ServletContextListener就起作用了
	//自动创建对象并调用contextInitialized上下文的初始化方法
	public class PermissionScanInitListener implements ServletContextListener {

	    @Autowired
	    private IPermissionService permissionService;

	    @Override
	    public void contextInitialized(ServletContextEvent sce) {
			System.out.println("权限初始化开始******************************************");
			permissionService.scanPermission();
			System.out.println("权限初始化结束******************************************");
	    }
	}